(function($, owner) {
	/**
	 * 用户登录
	 **/
	owner.login = function(loginInfo, callback) {
		callback = callback || $.noop;
		loginInfo = loginInfo || {};
		loginInfo.account = loginInfo.account || '';
		loginInfo.password = loginInfo.password || '';
		if(loginInfo.account.length <= 0) {
			return callback('账号不能为空');
		}
		if(loginInfo.password.length <= 0) {
			return callback('密码不能为空');
		}

		var postdata = {
			username: loginInfo.account.toLocaleLowerCase(),
			password: md5(loginInfo.password.toLocaleLowerCase()),
			version: '0.1',
			platform: 'merchant_android',
			token: 'f416b7333f412805f5f1def594bdcf93'
		};
		console.log(loginInfo.account.toLocaleLowerCase());
		console.log(loginInfo.password.toLocaleLowerCase());

		mui.ajax({
			type: "post",
			url:  "http://192.168.1.198:8080/SA_Mobile_Website/loginMerchant.jsp",
			data: postdata,
			dataType: 'json',
			timeout: 10000, //超时时间设置为10秒；
			success: function(result) {
				console.log(JSON.stringify(result));

				if(JSON.stringify(result).match("success") != null) {
					console.log(JSON.stringify(loginInfo));
					localStorage.setItem('$user', JSON.stringify(loginInfo));
					return callback();
				} else {
					return callback(result.Result);
				}
			},
			error: function(xhr, type, errorThrown) {
				//异常处理；
				console.log(JSON.stringify(xhr));
			}
		});

	};

}(mui, window.app = {}));